<?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:com="http://java.sun.com/jsf/composite/componentes"
      xmlns:f="http://java.sun.com/jsf/core">
<composite:interface componentType="br.senai.sc.hidroData.InputNumber">
    <composite:attribute name="label" type="String" />
    <composite:attribute name="max" type="String" default="999999999.99" />
    <composite:attribute name="min" type="String" default="0.00" />
    <composite:attribute name="required" type="boolean" default="false" />
    <composite:attribute name="sign" type="String" default="" />
    <composite:attribute name="signPosition" default="left" />
    <composite:attribute name="value" />
    
    <composite:editableValueHolder name="value" targets="input" />
</composite:interface>
<composite:implementation>

    <h:outputScript value="jquery.js" />
    <h:outputScript library="js" name="jquery.autoNumeric.js" />

    <span id="#{cc.clientId}">
        <com:formInput id="inputContainer" label="#{cc.attrs.label}">
            <p:inputText
                id="input"
                value="#{cc.attrs.value}"
                label="#{cc.attrs.label}"
                required="#{cc.attrs.required}"
                styleClass="input-numeric">
                <f:convertNumber type="number"  />
            </p:inputText>
        </com:formInput>
        
        <script type="text/javascript">
        $('##{cc.escapedClientId}\\:inputContainer\\:input').autoNumeric({
            aSep: '.',
            aDec: ',',
            altDec: '.',
            vMin: '#{cc.attrs.min}',
            vMax: '#{cc.attrs.max}',
            aSign: '#{cc.attrs.sign}',
            pSign: ('#{cc.attrs.signPosition}' == 'right' ? 's' : 'p')
        }).autoNumericSet('#{cc.attrs.value}');
        </script>
    </span>
</composite:implementation>
</html>